/**
 * @author gao
 * @date 2025/6/21 19:59
 */

public class Demo5 {
    public static void main(String[] args) {
        // 创建一个新的线程
        Thread thread = new Thread(() -> {
            while (true) {
                System.out.println("Hello Thread!");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });

        // 启动线程
        thread.start();

        // 无限循环
        while (true) {
            System.out.println("Hello Main!");
            try {
                // 主线程休眠1秒
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}